#include <iostream>
#include "../Utils/File.hpp"
#include "jsoncpp/JsonMap.h"

using namespace std;

int main()
{
    std::cout.setf(std::ios_base::boolalpha);

    std::string fileName = "test.json";
    sh::File file(fileName);
    file.open(std::ios_base::in);
    std::string jsonData = file.readAll();
    file.close();

    sh::JsonMap jsonMap(jsonData);
    cout << jsonMap.isParserOk() << endl;
    try
    {
        cout << jsonMap.formatJson() << endl;
        jsonMap.put("data", std::initializer_list<int>{1, 2, 34}, sh::Append);
        cout << jsonMap.formatJson() << endl;
        cout << jsonMap.get("a").toString() << endl;
    }
    catch (sh::JsonMapException &exception)
    {
        cout << exception.error() << endl;
        return 1;
    }
    return 0;
}
